package com.itheima.mapper;

import com.itheima.domain.IDCard;
import com.itheima.domain.Person;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @param
 * @return
 */
public interface PersonMapper {
    @Select("SELECT * FROM Person")
  @Results(id = "oto",value = {
          @Result(id = true,column = "id" ,property = "id"),
          @Result(column = "name",property = "name"),
          @Result(column = "age",property = "age"),
          @Result(property ="idCard",javaType = IDCard.class,column = "id",
          one =@One(select = "com.itheima.mapper.IDCardMapper.findById",fetchType = FetchType.LAZY))
  })
    List<Person> one_to_one();
}
